const mongoose = require('mongoose');
const FoodTypeSchema = require('../schema/foodtype.schema.js');

const FoodTypeModel = mongoose.model('Foodtype',FoodTypeSchema);

exports.findAll = function (callback){
    FoodTypeModel.find({},function(err,data){
        if(err){
            console.log(err);
            callback({status:false,data:{},message:'服务器异常'});
        }else{
            callback({status:false,data:data,message:''});
           
        }
    });
}
exports.findById = function(id,callback){
    FoodTypeModel.findOne({_id:id},function(err,data){
        if(err){
            console.log(err);
            callback({status:false,data:{},message:'服务器异常'});
        }else{
            if(data){
                callback({status:true,data:data,message:''});
            }else{
                callback({status:false,data:data,message:'暂无数据'});
            }
           
           
        }
    });
}
